import java.io.*;
import java.util.*;

public class FileRead
{
private	BufferedReader in;
private	BufferedReader in2;
   private double matrix [][];
public 	FileRead(String filename) throws IOException
   {  in = new BufferedReader(new FileReader(filename));
      in2= new BufferedReader(new FileReader(filename));
	   matrix = readData(in, in2); 
   
   }
 
   double[][] readData(BufferedReader in, BufferedReader in2) throws IOException
  {
   double arr [][];
   int cols;
   int rows=1;
   cols=new StringTokenizer(in2.readLine()," ").countTokens();
   while((in2.readLine())!=null) rows++;
    System.out.println("matrix is "+rows+"X"+cols);
    matrix=new double[rows][cols];
  StringTokenizer strt;
  String us;
    for(int i=0;i<rows;i++)
    {   us=in.readLine();
        strt=new StringTokenizer(us," ");
	  for(int j=0;j<cols;j++)
	  {
 	 matrix[i][j] = Double.parseDouble(strt.nextToken());
	  } 
    }
    System.out.println("Reading file.....");
  return matrix; 
  }
   public double [][] getMatrix(){return matrix;}
   public double [] getVector()
   { double []array=new double[matrix[0].length];
   if(matrix.length==1)
   {for(int i=0;i<matrix[0].length;i++)
	    array[i]=matrix[0][i];}
   else{array=null;}
   return array;
   }
}
